clear
close all
clc

%% Baseline results, country by country for countries in Latin America

    % choose the countries you want to run for in country_list_short
    % then run the following:
    
    % break down forest data to exclude forested regions of Peru
        fprintf('Now running split_GFC')
        split_GFC;

    % determine country bounds
        fprintf('Now defining country boundaries!')
        define_country_boundaries_LAC;

    % aggregate the population data to small cells within each country
        fprintf('Now running split_SEDAC')
        split_SEDAC_LAC;

    % break down income data into individual countries
        fprintf('Now running split_gecon')
        split_gecon_LAC;

    % break down topography data into individual countries
        fprintf('Now running split_ETOPO')
        split_ETOPO_LAC;
    
    % generate country grids and actual discretized networks
        fprintf('Now discretizing the network')
        make_country_graphs; 

        % Note that to create OSM travel times for robustness check you
        % need to run, after running make_country_graphs for the baseline case: 
        prepare_osm_data;
    
    % Before proceeding to the calibration and counterfactual, 
    % generate plots of baseline grids and income, population
        fprintf('Now plotting the baseline grids')
        plot_paper_graphs;   
    
    % I have the discretization spitting out the full graph
    % given parameters, make specific 
    % calibration
        fprintf('Now running the calibration for baseline results')
        run_calibration;    
    
    % counterfactuals
        fprintf('Now running the counterfactuals for baseline results')
        run_counterfactuals_LAC;

    % generate plots of counterfactual results 
        plot_cfactuals;      
    
    % prepare outcomes for tables
        make_summary_tables_revision;

%% Transnational countries

    % aggregate the population data to small cells within each country
        fprintf('Now running split_SEDAC')
        split_SEDAC_connected;

    % break down income data into individual countries
        fprintf('Now running split_gecon')
        split_gecon_connected;

    % break down topography data into individual countries
        fprintf('Now running split_ETOPO')
        split_ETOPO_connected;

    % prepare grids 
        connected_country_analysis;
       
    % calibration 
        run_calibration_connected;
   
    % counterfactuals
        run_counterfactuals_connected;
        plot_cfactuals_connected;

